package com.bite.redisdemo2.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sentinel")
public class RedisController {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @PostMapping("/set")
    public String set(@RequestParam String key, @RequestParam String value) {
        redisTemplate.opsForValue().set(key, value);
        return "SET OK (Sentinel)";
    }

    @GetMapping("/get")
    public String get(@RequestParam String key) {
        return String.valueOf(redisTemplate.opsForValue().get(key));
    }
}
